package kr.co.cherryt.util;

import java.util.HashMap;

/** UriManager
 * 응용프로그램에서 사용하는 각종 URI들을 한 곳에서 관리
 */
public class UrlManager {
	
	private UrlManager(){}
	
	private static final String DEF_PATH = "http://cherryt.co.kr";
	
    private static final int URL_NO_UNKNOWN = 100;
    
    private static final int URL_GEV_SPONSER_BASE = 200;
    private static final int URL_GOV_SPONSER_HNR = URL_GEV_SPONSER_BASE + 1;
    private static final int URL_GOV_SPONSER_MJ = URL_GEV_SPONSER_BASE + 2;
    private static final int URL_GOV_SPONSER_JYSJ = URL_GEV_SPONSER_BASE + 3;
    private static final int URL_GOV_SPONSER_MRHM = URL_GEV_SPONSER_BASE + 4;
    private static final int URL_GOV_SPONSER_MJND = URL_GEV_SPONSER_BASE + 5;
    private static final int URL_GOV_SPONSER_CJHK = URL_GEV_SPONSER_BASE + 6;
    private static final int URL_GOV_SPONSER_MSS = URL_GEV_SPONSER_BASE + 7;
    
    private static final int URL_ENTERPRISE_BASE = 300;
    private static final int URL_ENTERPRISE_CORPORATE = URL_ENTERPRISE_BASE + 1;
    private static final int URL_ENTERPRISE_SHARE = URL_ENTERPRISE_BASE + 2;
    
    private static HashMap<String, Integer> hashMap = new HashMap<String, Integer>();
    static {
    	addUri(DEF_PATH + "/index.php?m=1&mid=ct_gv_hnr", URL_GOV_SPONSER_HNR);
    	addUri(DEF_PATH + "/index.php?m=1&mid=ct_gv_mj", URL_GOV_SPONSER_MJ);
    	addUri(DEF_PATH + "/index.php?m=1&mid=ct_gv_jysj", URL_GOV_SPONSER_JYSJ);
    	addUri(DEF_PATH + "/index.php?m=1&mid=ct_gv_mrhm", URL_GOV_SPONSER_MRHM);
    	addUri(DEF_PATH + "/index.php?m=1&mid=ct_gv_mjnd", URL_GOV_SPONSER_MJND);
    	addUri(DEF_PATH + "/index.php?m=1&mid=ct_gv_cjhk", URL_GOV_SPONSER_CJHK);
    	addUri(DEF_PATH + "/index.php?m=1&mid=ct_gv_mss", URL_GOV_SPONSER_MSS);
    }
	
	private static void addUri(String path, int code){
		hashMap.put(path, code);
	}
	
	public static int matchUri(String path){
		return hashMap.get(path);
	}
	
	private static final int TYPE_URL_UNKNOWN = 1000;
	private static final int TYPE_URL_GOV_SPONSER = 1001;
	private static final int TYPE_URL_ENTERPRISE = 1002;
	private static final int TYPE_URL_PRIVATE = 1003;
    
	public static int getUrlType(String path){
		int uriCode = matchUri(path);
		switch(uriCode){
		case URL_GOV_SPONSER_HNR:
		case URL_GOV_SPONSER_MJ:
		case URL_GOV_SPONSER_JYSJ:
		case URL_GOV_SPONSER_MRHM:
		case URL_GOV_SPONSER_MJND:
		case URL_GOV_SPONSER_CJHK:
		case URL_GOV_SPONSER_MSS:
			return TYPE_URL_GOV_SPONSER;
		case URL_ENTERPRISE_CORPORATE:
		case URL_ENTERPRISE_SHARE:
			return TYPE_URL_ENTERPRISE;
		default:
			return TYPE_URL_UNKNOWN;
		}
	}
}

//http://cherryt.co.kr/ct/?mid=ct_mb_info       // 내 정보 (로그인 정보)
//http://cherryt.co.kr/ct/index.php?mid=ct_ad&m=1&act=dispMemberLoginForm
//http://cherryt.co.kr/ct/index.php?mid=ct_ad&m=1 // 로그인 되지 않은 상태
//http://cherryt.co.kr/ct/index.php?mid=ct_mb_join&m=1&act=dispMemberSignUpForm

//info// 기업광고
//http://cherryt.co.kr/ct/index.php?mid=ct_ad&m=1&act=dispMemberLoginForm
//http://cherryt.co.kr/ct/index.php?mid=ct_ad&act=rss&id=
//http://cherryt.co.kr/ct/index.php?mid=ct_ad&m=1&document
//http://cherryt.co.kr/ct/index.php?m=1&mid=ct_ad

//info// 열린광고 (개인광고)
//http://cherryt.co.kr/ct/index.php?m=1&mid=ct_review_personal_ad&act=dispBoardWrite
//http://cherryt.co.kr/ct/index.php?m=1&mid=ct_review_ucc&act=dispBoardWrite
//http://cherryt.co.kr/ct/index.php?m=1&mid=ct_personal_ad

//info// 나눔
//http://cherryt.co.kr/ct/ct_share/rss
//http://cherryt.co.kr/ct/index.php?m=1&mid=ct_share

//info// 창작공간(UCC)
//http://cherryt.co.kr/ct/index.php?m=1&mid=ct_ucc

//info// 커뮤니티
//http://cherryt.co.kr/ct/index.php?mid=ct_mb_tel&tel=
//http://cherryt.co.kr/ct/index.php?mid=ct_mb_tell

//info// 쇼핑
//http://cherryt.co.kr/ct/index.php?m=1&mid=ct_m_shop
//http://cherryt.co.kr/ct/index.php?mid=ct_m_shop&listStyle=gallery&search_target=title_content&search_keyword=%EC%B6%94%EC%B2%9C

//info// 기프티쇼
//http://cherryt.co.kr/ct/giftishow/

//info// 이벤트
//http://cherryt.co.kr/ct/index.php?m=1&mid=ct_event

//info// 정치 후원